// import store from '../store'
import {INCREMENTCOUNT,DECREMENTCOUNT} from '../constant/countConst'
const init = { count: 0 }

export default function countReducer(prevState = init, action) {
  const { type, data } = action

  // console.log(type, data,init);
  // console.log(init);

  switch (type) {
    case INCREMENTCOUNT:
      return { ...init, count: prevState.count + data }
      case DECREMENTCOUNT:
      return { ...init, count: prevState.count - data }
  }
  return prevState
}